package com.redrose.audioandvideo.ui;

import android.Manifest;
import android.os.Bundle;
import android.os.Environment;
import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.redrose.audioandvideo.R;
import com.redrose.audioandvideo.databinding.ActivityMainBinding;
import com.redrose.audioandvideo.ui.activitys.BaseActivity;
import com.redrose.audioandvideo.utils.LogUtils;
import com.redrose.audioandvideo.utils.Utils;

import java.io.File;

@Route(path = "/activity/main")
public class MainActivity extends BaseActivity<ActivityMainBinding> {
    private String[] permission = {Manifest.permission.CAMERA};

    @Override
    public void initData() {

    }

    @Override
    public int setLayout() {
        initState();
//        Utils.setStatusTextColor(true,this);
        File externalFilesDir = mContext.getExternalFilesDir(null);
        LogUtils.d("MainHandler", " 路径  getPath： " + externalFilesDir.getPath());
        LogUtils.d("MainHandler", " 路径  getAbsolutePath： " + externalFilesDir.getAbsolutePath());
        return R.layout.activity_main;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mBinding.setMainHandler(new MainHandler());
        LogUtils.d("MainActivity", "---onCreate---");
        if (!hasPermission(permission[0])) {
            requestPeermission(permission, 1000);
        }
    }

    public static class MainHandler {
        public void goToAudioActivity(View view) {
            int id = view.getId();
            switch (id) {
                case R.id.btn_audio:
                    ARouter.getInstance()
                            .build("/activity/audio")
                            .navigation();
                    break;
                case R.id.btn_video:
                    ARouter.getInstance()
                            .build("/activity/video")
                            .navigation();
                    break;
                case R.id.btn_video2:
                    ARouter.getInstance()
                            .build("/activity/video2")
                            .navigation();
                    break;
                case R.id.btn_dir:
                    String path = Environment.getExternalStorageState();
                    LogUtils.d("MainHandler", " 路径 ： " + path);
                    break;
                case R.id.btn_goto_scroll_activity:
                    ARouter.getInstance()
                            .build("/activity/scroll")
                            .navigation();
                    break;
                default:
                    break;
            }

        }

    }
}
